"use strict";

angular.module('app.yksensor', ['ui.router', 'restangular'])

.filter('type_filter', function() {
          return function(input) {
                // input是我们传入的字符串
                var ss = input.match(/(\S*)\(/)[1];
               return ss;  
             }
  })
.filter('length_filter', function() {
          return function(input) {
                // input是我们传入的字符串
                var type = input.match(/(\S*)\(/)[1];
                if(type == "double" || type == "float"){//double(12,2)
                  var length = input.match(/\((\S*)\,/)[1];
                }else{//int(4)
                  var length = input.match(/\((\S*)\)/)[1];
                }           
               return length;  
             }
  })
.filter('xiao_filter', function() {
          return function(input) {
                // input是我们传入的字符串
               var type = input.match(/(\S*)\(/)[1];
                if(type == "double" || type == "float"){//double(12,2)
                  var xiao = input.match(/\,(\S*)\)/)[1];
                }else{//int(4)
                  var xiao = "0";
                }           
               return xiao;  
             }
  })
.filter('signalfilter', function () {
    return function (input) {
        // input是我们传入的字符串
        if (input < 20)
            return "styles/img/signal-L.png";
        else
            return "styles/img/signal-H.png";
    }
})

.filter('ele_chargefilter', function () {
    return function (input) {
        // input是我们传入的字符串
        if (input == "1")
            return "styles/img/ele-L.png";
        else
            return "styles/img/ele-H.png";
    }
})
.filter('status', function () {
    return function (input) {
        // input是我们传入的字符串
        if (input == "0")
            return "Alarm";
        else
            return "Online";
    }
})
.filter('alarmcode', function () {
    return function (input) {
        // input是我们传入的字符串
        if (input == "0")
            return "Alarm";
        else
            return "Online";
    }
})
.filter('status_tag', function () {
    return function (input) {
        // input是我们传入的字符串
        if (input == "失效")
            return "Offline";
        else
            return "Online";
    }
})
.filter('handle_status', function () {
    return function (input) {
        // input是我们传入的字符串
        if (input == "0")
            return "未处理";
        else
            return "已处理";
    }
})
.config(function ($stateProvider,RestangularProvider) {

    $stateProvider
         .state('app.yksensor', {
             abstract: true,
             data: {
                 title: '油库管理'
             }
         })

        .state('app.yksensor.log', {
            url: '/yk_log',
            views: {
                "content@app": {
                    templateUrl: 'app/yksensor/views/log.html',
                    controller: 'YKLogCtrl'
                }
            },
            data: {
                title: '登陆日志',
                level:"level_8"
            }
        })
        .state('app.yksensor.device', {
            url: '/yk_device',
            views: {
                "content@app": {
                    templateUrl: 'app/yksensor/views/device.html',
                    controller: 'YKDeviceCtrl'
                }
            },
            data: {
                title: '设备管理',
                level:"level_8"
            }
        })
        .state('app.yksensor.data', {
            url: '/yk_data',
            views: {
                "content@app": {
                    templateUrl: 'app/yksensor/views/data.html',
                    controller: 'YKDataCtrl'
                }
            },
            data:{
                title: '实时数据',
                level:"level_8"
            }
        })
        .state('app.yksensor.historicaldata', {
            url: '/yk_historicaldata/:deviceid',
            views: {
                "content@app": {
                    templateUrl: 'app/yksensor/views/historicaldata.html',
                    controller: 'YKHistoricaldataCtrl'
                }
            },
            data:{
                title: '历史数据',
                level:"level_8"
            }
        })

        .state('app.yksensor.alert', {
            url: '/yk_alert',
            views: {
                "content@app": {
                    templateUrl: 'app/yksensor/views/alert.html',
                    controller: 'YKAlertCtrl'
                }
            },
            data:{
                title: '警报处理',
                level:"level_8"
            }
        })

        .state('app.yksensor.alertsite', {
            url: '/yk_alertsite',
            views: {
                "content@app": {
                    templateUrl: 'app/yksensor/views/alertsite.html',
                    controller: 'YKAlertsiteCtrl'
                }
            },
            data:{
                title: '警报设置',
                level:"level_8"
            }
        })

        .state('app.yksensor.sim', {
            url: '/yk_sim',
            views: {
                "content@app": {
                    templateUrl: 'app/yksensor/views/sim.html',
                    controller: 'YKSimCtrl'
                }
            },
            data:{
                title: 'SIM卡信息管理',
                level:"level_8"
            }
        })

        .state('app.yksensor.charts', {
            url: '/yk_sensorcharts/:deviceid/:devicetype',
            views: {
                "content@app": {
                    templateUrl: 'app/yksensor/views/sensorcharts.html',
                    controller: 'YKSensorChartCtrl'
                }
            },
            data: {
                title: '数据曲线',
                level:"level_8"
            }
        })
        .state('app.yksensor.tankcharts', {
            url: '/yk_tankcharts/:tankid',
            views: {
                "content@app": {
                    templateUrl: 'app/yksensor/views/tankcharts.html',
                    controller: 'TankChartsCtrl'
                }
            },
            resolve: {
                scripts: function(lazyScript){
                    return lazyScript.register([
                        'js/plugin/flot/jquery.flot.tickrotor.js'
                    ]);
                }
            },
            data: {
                title: '油罐温度曲线',
                level:"level_8"
            }
        })
        .state('app.yksensor.maps', {
            url: '/yk_maps',
            views: {
                "content@app": {
                    templateUrl: 'app/yksensor/views/maps.html',
                    controller: 'MapCtrl'
                }
            },
            data: {
                title: '地图',
                level:"level_8"
            }
        })
        .state('app.yksensor.store', {
            url: '/yk_store',
            views: {
                "content@app": {
                    templateUrl: 'app/yksensor/views/store.html',
                    controller: 'YKStoreCtrl'
                }
            },
            data: {
                title: '库区总览',
                level:"level_8"
            }
        })
        .state('app.yksensor.storeDetail', {
            url: '/yk_storedetail',
            views: {
                "content@app": {
                    templateUrl: 'app/yksensor/views/storeDetail.html',
                    controller: 'YKStoreDetailCtrl'
                }
            },
            data: {
                title: '油罐详情',
                level:"level_8"
            }
        })
    //     .state('app.yksensor.query', {
    //         url: '/query',
    //         views: {
    //             "content@app": {
    //                 templateUrl: 'app/yksensor/views/query.html',
    //             }
    //         },
    //         data: {
    //             title: '下发查询',
    //             level:"level_5"
    //         }
    //     })
    //    .state('app.yksensor.protocol', {
    //         url: '/yksensorpro',
    //         views: {
    //             "content@app": {
    //                 templateUrl: 'app/yksensor/views/sensorpro.html',
    //                 controller: 'SensorProtocolCtrl'
                     
    //             }
    //         },
    //         data:{
    //             title: '传感器协议管理',
    //             level:"level_5"
    //             }
    //    })
 
       
});


